<?php
/*

Welcome to NMOX Server PHP-MAX! You're currently viewing a comment within the
PHP code that generates the index page of the tutorial. This file should be
located at /nmox/tutorial/index.php

Everything in this first page is intended to "feel" like a simple PHP page.
There is this small code section at the top, and then the rest is hand-typed
XHTML with only two short-tag PHP insertions. As the tutorial progresses, each
page will implement more and more NMOX Server stuff, explaining each task as we
hand it off for NMOX to handle for us.

Here's what's going on in this introduction page:

First, we are importing the x.php file. It is stored one directory above this
one, so we use two dots to refer to that relative path. Once imported, we have
access to ALL the functionality available within NMOX Server PHP-MAX! This is
very powerful, but not the most efficient way to use NMOX Server. You'll learn
about efficiency later on in this tutorial. For now, focus on learning how NMOX
Server can handle things for you. Later, when you want to streamline your work,
you can delve into the deeper aspects available to you.

Having imported everything via the x.php file, we set a simple string variable
to hold some text we'll use as an example later on.

This tutorial assumes you have a working copy of NMOX Server PHP-MAX installed
and configured, so if you haven't gotten that far yet -- stop and take care of
that first!

You will want to view this file two ways as we go through the tutorial:
1) As you are now, within a text editor so you can see the raw PHP code
2) Within your web browser. I suggest Firefox 3. ;]

That way you can view both NMOX Server's instructions to create XHTML, and also
view the creation itself. If it helps you to gain a better understanding of what
is going on, try making small changes to these tutorial files and view the
resulting output. You can always download another fresh copy of this tutorial at
http://nmox.org/

When you finish with this introduction page, move your browser and your text
editor on to page1.php in this same folder. Have fun!

 *
 * @author David Christian Liedle <david.liedle@gmail.com>
 * @link   http://nmox.org/
 *
 */

require_once('../x.php');

$example_paragraph = 'Take a look at the source of this PHP file to see how this
                      paragraph was created.';

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <link rel="Shortcut Icon"
              href="../../favicon.ico"
              type="image/x-icon" />
        <title>NMOX Server PHP-MAX Tutorial</title>

        <meta name="Description" content="NMOX Server PHP-MAX Tutorial" />
        <meta name="Keywords" content="NMOX,
                                       Server,
                                       PHP-MAX,
                                       New Media On X,
                                       Tutorial" />

    </head>

   <body style="width: 720px; font-family: Georgia">
    
        <p id="top">
            <a href="../../" title="Navigate &#8216;above&#8217; the /nmox/
                             folder to your website.">Your Site</a> &rsaquo;
            <a href="../" title="/nmox/">NMOX Server Folder</a> &rsaquo;
            <a href="./" title="/nmox/tutorial/">Tutorial Folder</a> &rsaquo;
            Start Page (a.k.a., <code>/nmox/tutorial/index.php</code>)
        </p>
        <hr />
        
        <h1>NMOX Server PHP-MAX Tutorial</h1>
        <h2>Introduction</h2>
        
        <p><a href="../" title="/nmox/">Up</a>
           <a href="page1.php" title="/nmox/tutorial/page1.php">Next</a></p>
        
        <p>Welcome to NMOX Server! You are looking at the first page in a little
        tutorial on the PHP-MAX version of NMOX Server. My name is David
        Christian Liedle, and I&#8217;m the author of both this tutorial and
        NMOX itself. Hopefully I can give you a fairly painless introduction to
        my work and, in doing so, get you quickly up to speed with your own work
        as well.</p>
        
        <p>NMOX Server PHP-MAX can be installed in 3 ways:<br />
            <ol>
                <li><strong>Core:</strong> Just the /nmox folder; counts on you
                to do the development.</li>
                <li><strong>Proto:</strong> A complete site, from /htdocs to
                /htdocs/nmox; development has been done for you.</li>
                <li><strong>Xtreme:</strong> Allow NMOX Server to flow up into your
                server&#8217;s veins and manage itself for you. ;]</li>
            </ol>
        As both Proto and Xtreme consist of finished work and ample support, I
        will gear this tutorial towards fresh development using Core, so you can
        see how to create and extend content within the NMOX system.</p>
        
        <p>We will be starting off with some PHP development basics, and
        introducing some syntactic sugar provided by NMOX to illustrate these
        basics. If you are a seasoned hacker, a bit&#8211;miser in the RAM
        department, or obsessed with clock cycles, never fear &#8212; NMOX
        Server can be used completely &#8220;sugar&#8211;free&#8221;, and such
        techniques will be introduced later on in this tutorial.</p>
        
        <? /*                       PEEK-A-BOO!                            */ ?>
        <p>First things first: this tutorial assumes that you have access to the
        source files of which this tutorial consists. You can&#8217;t just use
        &#8220;view source&#8221; on your browser and see everything I&#8217;ll
        be talking about. NMOX Server <em>generates</em> that source, and your
        browser turns it into this web page. The code that tells NMOX Server
        <em>how</em> to generate that stuff can only be viewed by opening the
        <code>.php</code> files in a text editor directly. The reason for that
        is kind of obvious, but in case you were wondering <?=EMDASH?> all files
        on a properly&#8211;configured server that end in <code>.php</code> are
        processed by the PHP interpreter, and any output created by that process
        is sent to your browser. In fact, <em>only</em> that output is sent; not
        the original code that generated it. Yes, yes its true&#8212;even source
        code can have source code. Heh heh.</p>
        
        <p>So what&#8217;s the point? Why not just type everything out by hand?
        Well, hopefully that will become obvious throughout this tutorial.
        Really, it can be summed up in a single word:
        <strong>POWER</strong>.</p>
        
        <p>Let&#8217;s start digging in, shall we? Do a quick &#8220;view
        source&#8221; in your browser, and take a look two paragraphs up, just
        between <code>&#8220;&hellip;but in case you were
        wondering&hellip;&#8221;</code> and <code>&#8220;&hellip;all files on a
        properly&#8211;configured server that&hellip;&#8221;</code>, where the
        em&#8211;dash is. See how the HTML entity is created by the code
        <code>&amp;#8212;</code>? I didn&#8217;t actually type <em>that</em>
        HTML entity to get it in there though. I used NMOX Server PHP-MAX to
        generate the HTML entity for me.</p>
        
        <p>Now let&#8217;s take a look at how that happened. Grab your favorite
        text editor and open the <code>index.php</code> file inside the tutorial
        folder. The full path starting from the default NMOX Server folder is:
        <code>/nmox/tutorial/index.php</code></p>
        
        <p>Got it open? The file starts with some comments on the PHP code, then
        there are a couple of tasks handled in PHP, then the PHP code block ends
        and everything below is hand&#8211;typed XHTML. Everything, that is,
        except for a few interspersed short PHP tags. The first of these short
        tags is simply a comment to help you quickly locate the paragraph we
        were just looking at. Scroll down to about line 105, and you should see
        that paragraph under the words
        <code>&#8220;PEEK&#8211;A&#8211;BOO!&#8221;</code>. Within that
        paragraph, where you saw the <code>&amp;#8212;</code> in your browser as
        you viewed the page source, you will see the instruction that created
        that <code>&amp;#8212;</code> code: <code>&lt;?=EMDASH?&gt;.</p>
        
        <p>That <code>EMDASH</code> there is a constant. That is, it's a
        variable that is defined once and never changed again. NMOX Server has a
        file dedicated to such definitions, called <code>constantine.php</code>.
        The path to that file is: <code>/nmox/main/constantine.php</code></p>
        
        <p><code>constantine.php</code> is chock&#8211;full of goodies, from the
        basic HTML entities that you will use often (LDQUO, RDQUO, ENDASH, etc.)
        to shortcuts for formatting characters like tabs, soft tabs, newlines,
        to system&#8211;wide constants such as the object types you will be
        learning about shortly.</p>
        
        <p>Now let&#8217;s take a look at one more thing before moving on to the
        next page in the tutorial. The following paragraph uses a simple command
        from the xStatic library. Open this <code>index.php</code> page in your
        text editor, and find that paragraph to see how it is being created.</p>
        
        <?=xP($example_paragraph)?>
        
        <p>The code you&#8217;re looking for looks just like this:<br />
        <code>&lt;?=xP($example_paragraph)?&gt;</code>
        </p>
        
        <p>I have set a simple string variable at the top of this page, inside
        the PHP block, giving <code>$example_paragraph</code> the value of the
        text that I wanted to display there. I &#8216;fed&#8217; that value into
        the <code>xP()</code> function from the xStatic library, which
        &#8216;wrapped&#8217; that value with <code>&lt;p&gt;</code> and
        <code>&lt;/p&gt;</code>, which I placed inline with my other content on
        this page using the short PHP tag instructing the returned value to echo
        in place. (The short tag <code>&lt;?=</code> instructs PHP to echo any
        variable or value returned from a function).</p>
        
        <p>That&#8217;s all for this introductory page. <a href="page1.php"
        title="/nmox/tutorial/page1.php">Continue</a> on to the next page of the
        tutorial, and get ready to start putting NMOX Server to work!</p>
        
        <p><a href="#top" title="Jump to the top of this page">Top</a>
           <a href="../" title="/nmox/">Up</a>
           <a href="page1.php" title="/nmox/tutorial/page1.php">Next</a></p>
        
        <hr />
        <p><center>Copyright &copy;2008 David Christian Liedle. All rights
        reserved.<br />
        <a href="http://nmox.org/" title="Visit NMOX.org">http://nmox.org/</a>
        </center>
        </p>
        
    </body>
    
</html>
